package com.nd.test.service;

import java.util.List;
import java.util.Date;

import model.po.CouponsModel;
import com.nd.test.vo.CouponsModelVo;
import com.nd.test.repository.CouponsModelRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**   
 * Create by apisdk 
 */
@Service
public class CouponsModelService {
	@Autowired
	private CouponsModelRepository couponsModelRepository;

	/**
	* @description create model
	* @return
	*/
	public CouponsModelVo createCouponsModel(CouponsModelVo couponsModelVo) throws Exception {
		CouponsModel couponsModel = new CouponsModel();
		BeanUtils.copyProperties(couponsModelVo, couponsModel);
		couponsModel =  couponsModelRepository.save(couponsModel);
		BeanUtils.copyProperties(couponsModel, couponsModelVo);
		return couponsModelVo;
	}

	/**
	* @description get model through id
	* @return
	*/
	public List<CouponsModelVo></Vo> getCouponsModelByExample(CouponsModelVo couponsModelVo){
		CouponsModel couponsModel = new CouponsModel();
		BeanUtils.copyProperties(couponsModelVo, couponsModel);
	}

	/**
	* @description update model through id
	* @return
	*/
	public CouponsModelVo updateCouponsModelById(@PathVariable String id,@RequestBody CouponsModelVo couponsModelVo){
		//TODO to finish update code
		return couponsModelVo;
	}

	/**
	* @description delete model through id
	* @return
	*/
	public void deleteCouponsModelById(@PathVariable String id){
		CouponsModel couponsModel =  couponsModelRepository.findOne(id);
		if(couponsModel!=null){
			couponsModelRepository.delete(couponsModel);
		}
		return;
	}

}
